﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using YXShop.Web;
using YXShop.Model.Order;
using System.Text.RegularExpressions;
using System.Data;
namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        public string ShoppingCar()
        {
            string mystyle = this.Label_Inserted;
            string TempletLayout = this.GetParamValue("YX:TempletLayout");
            StringBuilder shtml = new StringBuilder();
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();

            //添加数据
            int productid = ChangeHope.WebPage.PageRequest.GetInt("q_productid");
            int productCount = ChangeHope.WebPage.PageRequest.GetInt("q_proCount");
            if (productCount < 0)
            {
                productCount = 1;
            }
            string productSpecification = ChangeHope.WebPage.PageRequest.GetString("q_proSpecification");
            string fittingsProductId = ChangeHope.WebPage.PageRequest.GetString("q_fittingsProId");
            string fittingsProductCount = ChangeHope.WebPage.PageRequest.GetString("q_fittingsProCount");
            int fittingsId = ChangeHope.WebPage.PageRequest.GetInt("q_proSpareparId");
            
            ProfileCommon Profile = new ProfileCommon();
            if (productid > 0)
            {
                Profile.ShoppingCart.Add(productid.ToString(), productSpecification, productCount, fittingsProductId, fittingsProductCount, fittingsId);
                HttpContext.Current.Profile.Save();
                string ReturnUrl = Common.UrlStr("shoppingcart", "", "product/");
                HttpContext.Current.Response.Redirect(ReturnUrl);
            }

            ICollection<CartItemInfo> cart = Profile.ShoppingCart.CartItems;

            YXShop.BLL.Product.ProductInfo productbll = new YXShop.BLL.Product.ProductInfo();
            YXShop.BLL.Product.ProductSpecification spebll = new YXShop.BLL.Product.ProductSpecification();
            YXShop.BLL.Product.ProductSparepart spabll = new YXShop.BLL.Product.ProductSparepart();
            Common dp = new Common();
            string StrContent = "";
            if (cart.Count > 0)
            {
                if (!string.IsNullOrEmpty(mystyle))
                {
                    string pattern = @"\{\#[\s\S]*?\#\}";
                    string tempfinallyconent = mystyle;
                    StringBuilder GetTemp = new StringBuilder();
                    MatchCollection macths = Regex.Matches(tempfinallyconent, pattern);
                    string Str_Tag = "";
                    string temptag = "";
                    foreach (Match macth in macths)
                    {
                        temptag = macth.ToString();
                        int templength = temptag.ToString().IndexOf("{#") + 2;
                        int templength2 = temptag.ToString().IndexOf("#}");
                        if (temptag.ToString().Substring(templength, templength2 - templength).ToString() != null)
                        {
                            Str_Tag = temptag.ToString().Substring(templength, templength2 - templength);
                        }
                    }

                    if (sp.IsPayMentWebOperation)
                    {
                        StringBuilder cartInfo = new StringBuilder();
                        double productTotalPrice = 0;
                        double productTotalWeight = 0;
                        double productTotalIntegral = 0;
                        int productTotalCount = 0;
                        foreach (CartItemInfo info in cart)
                        {
                            YXShop.Model.Product.ProductInfo productmodel = productbll.GetModel(int.Parse(info.ProductId));
                            if (productmodel != null)
                            {
                                if (Str_Tag != "")
                                {
                                    StrContent = Str_Tag;
                                }
                                else
                                {
                                    StrContent = mystyle;
                                }
                                double price = double.Parse(productmodel.pro_ShopPrice.ToString());
                                //配件
                                string fittingProductInfo = "";
                                double fittingTotalPrice = 0;
                                int fittingProductCount = 0;
                                double fittingProductWeight = 0;
                                double fittingProductIntergal = 0;

                                YXShop.Common.ProductInfo.FittingDisposal(info.SparepartId, info.FittingsProductId, info.FittingsProductCount, out fittingProductCount, out fittingProductInfo, out fittingTotalPrice, out fittingProductWeight, out fittingProductIntergal);
                                //规格
                                
                                string memberPrice = productmodel.pro_RatingDiscount;
                                string productNo = productmodel.pro_NO;
                                
                                if (!string.IsNullOrEmpty(productmodel.pro_Specifications.Trim()))
                                {
                                    YXShop.Common.ProductInfo.SpecificationDisposal(Convert.ToInt32(info.ProductId), info.Specification, memberPrice, price, out price, out productNo);
                                }
                                double count = 0;
                                /*
                                 *修改人:ym
                                 *修改时间:2009.10.09
                                 */
                                count = double.Parse(info.Quantity.ToString());
                                double total = (price * count) + fittingTotalPrice;
                                if (StrContent.IndexOf("[#CheckBox]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#CheckBox]", "<input id=\"cbTm\" type=\"checkbox\" name=\"ShoppCartID\" value=\"" + info.CartKey + "\" />");
                                }
                                if (StrContent.Contains("[#Pro_ItmeNo]"))
                                {
                                    StrContent = StrContent.Replace("[#Pro_ItmeNo]", productNo);
                                }
                                if (StrContent.IndexOf("[#Pro_ID]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_ID]", info.ProductId);
                                }
                                if (StrContent.Contains("[#Pro_Url]"))
                                {
                                    StrContent = StrContent.Replace("[#Pro_Url]", Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/"));
                                }
                                if (StrContent.IndexOf("[#Pro_Images]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_Images]", sp.DummyPaht + productmodel.pro_Thumbnail);
                                }
                                if (StrContent.IndexOf("[#Pro_Name]") > -1)
                                {
                                    string strUrl = Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/");
                                    string specification = info.Specification;
                                    if (!string.IsNullOrEmpty(specification.Trim()))
                                    {
                                        specification = "(" + specification + ")";
                                    }
                                    StrContent = StrContent.Replace("[#Pro_Name]", "<a href=" + strUrl + " target='_blank'>" + productmodel.pro_Name + "&nbsp;" + specification + "</a>&nbsp;&nbsp;" + fittingProductInfo + "");
                                }
                                if (StrContent.IndexOf("[#Pro_CID]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_CID]", productmodel.pro_CID);
                                }
                                if (StrContent.IndexOf("[#Pro_Price]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_Price]", productmodel.pro_MarketPrice.ToString());
                                }
                                if (StrContent.IndexOf("[#Pro_ShopPrice]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_ShopPrice]", price.ToString("f2"));
                                }
                                if (StrContent.IndexOf("[#Pro_Integral]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_Integral]",(Convert.ToDouble(productmodel.pro_DonateIntegral) + fittingProductIntergal).ToString());
                                }
                                if (StrContent.IndexOf("[#Pro_NeedIntegral]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_NeedIntegral]", productmodel.pro_IntegralPrice.ToString());
                                }
                                if (StrContent.IndexOf("[#Pro_NeedDummyMoney]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_NeedDummyMoney]", productmodel.pro_EPoints.ToString());
                                }
                                if (StrContent.IndexOf("[#Pro_Count]") > -1)
                                {
                                    /**
                                     * kevin
                                     * 修改时间：2009-12.14
                                     */
                                    StrContent = StrContent.Replace("[#Pro_Count]", "<input style=\"width: 36px\" onblur=\"UpdataShoppCart(this.value,'" + info.CartKey + "','" + productmodel.pro_ID + "')\" value=\"" + count.ToString() + "\" type=\"text\" />");
                                }
                                if (StrContent.IndexOf("[#Pro_Total]") > -1)
                                {
                                    StrContent = StrContent.Replace("[#Pro_Total]", total.ToString("f2"));
                                }
                                productTotalPrice += total;
                                productTotalCount += Convert.ToInt32(count);
                                productTotalWeight += (Convert.ToDouble(productmodel.pro_Weight) * info.Quantity)+fittingProductWeight;
                                productTotalIntegral += (Convert.ToDouble(productmodel.pro_DonateIntegral)*info.Quantity)+ fittingProductIntergal;
                                cartInfo.Append(StrContent);
                            }


                        }
                        if (mystyle.IndexOf("[#Pro_TotalPrice]") > -1)
                        {
                            mystyle = mystyle.Replace("[#Pro_TotalPrice]", productTotalPrice.ToString());
                        }
                        if (mystyle.Contains("[#Pro_TotalProductCount]"))
                        {
                            mystyle = mystyle.Replace("[#Pro_TotalProductCount]", productTotalCount.ToString());
                        }
                        if (mystyle.IndexOf("[#Pro_TotalWeight]") > -1)
                        {
                            mystyle = mystyle.Replace("[#Pro_TotalWeight]", productTotalWeight.ToString());
                        }
                        if (mystyle.IndexOf("[#Pro_TotalInter]") > -1)
                        {
                            mystyle = mystyle.Replace("[#Pro_TotalInter]", productTotalIntegral.ToString());
                        }

                        if (mystyle.IndexOf("[#Pro_ContinueButton]") > -1)
                        {
                            string continueButton = "<input type=\"button\" name=\"ContinueButton\" id=\"ContinueButton\" onclick=\"javascript:window.history.back();\" value=\" \" />";
                            mystyle = mystyle.Replace("[#Pro_ContinueButton]", continueButton);
                        }

                        if (mystyle.IndexOf("[#Pro_Settlement]") > -1)
                        {
                            string OrderUrl = Common.UrlStr("makeorders", "UserTypeId=0;UserId=0", "product/");
                            string settlement = "<input type=\"button\" onclick=\"javascript:window.location.href='" + OrderUrl + "'\" name=\"settlement\" id=\"settlement\"  value=\" \" />";
                            mystyle = mystyle.Replace("[#Pro_Settlement]", settlement);
                        }

                        if (mystyle.IndexOf("[#Pro_DeteleButton]") > -1)
                        {
                            mystyle = mystyle.Replace("[#Pro_DeteleButton]", "<input type=\"button\" id=\"DeteleButton\" onclick=\"AbuthDle()\" value=\"删除\"></input>");
                        }
                        if (Str_Tag != "")
                        {
                            if (cartInfo.ToString() != string.Empty)
                            {
                                mystyle = mystyle.Replace(temptag, cartInfo.ToString());
                            }
                            else
                            {
                                mystyle = mystyle.Replace(temptag, "");
                            }
                            shtml.Append(mystyle);
                        }
                        else
                        {
                            shtml.Append(cartInfo.ToString());
                        }
                        if (Str_Tag == "")
                        {
                            string ShopUrl = Common.UrlStr("productclass", "", "product/");
                            string OrderUrl = "";
                            if (HttpContext.Current.Session["MemberID"] != null)
                            {
                                OrderUrl = Common.UrlStr("makeorders", "UserTypeId=0;UserId=" + HttpContext.Current.Session["MemberID"].ToString(), "product/");
                            }
                            else
                            { OrderUrl = Common.UrlStr("makeorders", "UserTypeId=0;UserId=0", "product/"); }
                            shtml.Append("<ul class=\"shop5\">");
                            shtml.Append("<li class=\"shop5-1\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_img3.jpg\"><input type=\"button\" onclick=\"AbuthDle()\" value=\"删除\"></input></li>");
                            shtml.Append("<li class=\"shop5-2\"><a href=\"javascript:window.location.reload();\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt1.jpg\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt2.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + ShopUrl + "'\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt3.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + OrderUrl + "'\" border=\"0\"></a></li>");
                            shtml.Append("</ul>");
                        }
                    }
                    else
                    {
                        #region 支付给运营方
                        string showContent = string.Empty;

                        double productTotalPrice = 0;
                        double productTotalWeight = 0;
                        double productTotalIntegral = 0;
                        StringBuilder catrInfos = new StringBuilder();
                        foreach (CartItemInfo info in cart)
                        {
                            YXShop.Model.Product.ProductInfo productmodel = productbll.GetModel(int.Parse(info.ProductId));
                            if (productmodel != null)
                            {
                                if (productmodel.pro_PutoutType == 0)
                                {
                                    if (Str_Tag != "")
                                    {
                                        StrContent = Str_Tag;
                                    }
                                    else
                                    {
                                        StrContent = mystyle;
                                    }
                                    double price = double.Parse(productmodel.pro_ShopPrice.ToString());
                                    //配件
                                    string fittingProductInfo = "";
                                    double fittingTotalPrice = 0;
                                    int fittingProductCount = 0;
                                    double fittingProductWeight = 0;
                                    double fittingProductIntergal = 0;
                                    YXShop.Common.ProductInfo.FittingDisposal(info.SparepartId, info.FittingsProductId, info.FittingsProductCount, out fittingProductCount, out fittingProductInfo, out fittingTotalPrice, out fittingProductWeight, out fittingProductIntergal);
                                    //规格

                                    string memberPrice = productmodel.pro_RatingDiscount;
                                    string productNo = productmodel.pro_NO;

                                    if (!string.IsNullOrEmpty(productmodel.pro_Specifications.Trim()))
                                    {
                                        YXShop.Common.ProductInfo.SpecificationDisposal(Convert.ToInt32(info.ProductId), info.Specification, memberPrice, price, out price, out productNo);
                                    }
                                    double count = 0;
                                    /*
                                     *修改人:ym
                                     *修改时间:2009.10.09
                                     */
                                    count = double.Parse(info.Quantity.ToString());
                                    double total = (price * count) + fittingTotalPrice;
                                    if (StrContent.IndexOf("[#CheckBox]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#CheckBox]", "<input id=\"cbTm\" type=\"checkbox\" name=\"ShoppCartID\" value=\"" + info.CartKey + "\" />");
                                    }
                                    if (StrContent.Contains("[#Pro_ItmeNo]"))
                                    {
                                        StrContent = StrContent.Replace("[#Pro_ItmeNo]", productNo);
                                    }
                                    if (StrContent.IndexOf("[#Pro_ID]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_ID]", info.ProductId);
                                    }
                                    if (StrContent.Contains("[#Pro_Url]"))
                                    {
                                        StrContent = StrContent.Replace("[#Pro_Url]", Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/"));
                                    }
                                    if (StrContent.IndexOf("[#Pro_Images]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_Images]", sp.DummyPaht + productmodel.pro_Thumbnail);
                                    }
                                    if (StrContent.IndexOf("[#Pro_Name]") > -1)
                                    {
                                        string strUrl = Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/");
                                        string specification = info.Specification;
                                        if (!string.IsNullOrEmpty(specification.Trim()))
                                        {
                                            specification = "(" + specification + ")";
                                        }
                                        StrContent = StrContent.Replace("[#Pro_Name]", "<a href=" + strUrl + " target='_blank'>" + productmodel.pro_Name + "&nbsp;" + specification + "</a>" + fittingProductInfo + "");
                                    }
                                    if (StrContent.IndexOf("[#Pro_CID]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_CID]", productmodel.pro_CID);
                                    }
                                    if (StrContent.IndexOf("[#Pro_Price]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_Price]", productmodel.pro_MarketPrice.ToString());
                                    }
                                    if (StrContent.IndexOf("[#Pro_ShopPrice]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_ShopPrice]", price.ToString("f2"));
                                    }
                                    if (StrContent.IndexOf("[#Pro_Integral]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_Integral]", (Convert.ToDouble(productmodel.pro_DonateIntegral) + fittingProductIntergal).ToString());
                                    }
                                    if (StrContent.IndexOf("[#Pro_NeedIntegral]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_NeedIntegral]", productmodel.pro_IntegralPrice.ToString());
                                    }
                                    if (StrContent.IndexOf("[#Pro_NeedDummyMoney]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_NeedDummyMoney]", productmodel.pro_EPoints.ToString());
                                    }
                                    if (StrContent.IndexOf("[#Pro_Count]") > -1)
                                    {
                                        /**
                                        * kevin
                                        * 修改时间：2009-12.14
                                        */
                                        StrContent = StrContent.Replace("[#Pro_Count]", "<input style=\"width: 36px\" onblur=\"UpdataShoppCart(this.value,'" + info.CartKey + "','" + productmodel.pro_ID + "')\" value=\"" + count.ToString() + "\" type=\"text\" />");
                                    }
                                    if (StrContent.IndexOf("[#Pro_Total]") > -1)
                                    {
                                        StrContent = StrContent.Replace("[#Pro_Total]", total.ToString("f2"));
                                    }
                                    productTotalPrice += total;
                                    productTotalWeight += (Convert.ToDouble(productmodel.pro_Weight) * info.Quantity) + fittingProductWeight;
                                    productTotalIntegral += (Convert.ToDouble(productmodel.pro_DonateIntegral) * info.Quantity) + fittingProductIntergal;
                                    catrInfos.Append(StrContent);
                                }
                            }

                        }
                        string websiteContent = mystyle;
                        if (websiteContent.IndexOf("[#Pro_TotalPrice]") > -1)
                        {
                            websiteContent = websiteContent.Replace("[#Pro_TotalPrice]", productTotalPrice.ToString());
                        }
                        if (mystyle.IndexOf("[#Pro_TotalWeight]") > -1)
                        {
                            websiteContent = websiteContent.Replace("[#Pro_TotalWeight]", productTotalWeight.ToString());
                        }
                        if (mystyle.IndexOf("[#Pro_TotalInter]") > -1)
                        {
                            websiteContent = websiteContent.Replace("[#Pro_TotalInter]", productTotalIntegral.ToString());
                        }

                        if (websiteContent.IndexOf("[#Pro_ContinueButton]") > -1)
                        {
                            string continueButton = "<input type=\"button\" name=\"ContinueButton\" id=\"ContinueButton\" onclick=\"javascript:window.history.back();\" value=\" \" />";
                            websiteContent = websiteContent.Replace("[#Pro_ContinueButton]", continueButton);
                        }

                        if (websiteContent.IndexOf("[#Pro_Settlement]") > -1)
                        {
                            string OrderUrl = Common.UrlStr("makeorders", "UserTypeId=0;UserId=0", "product/");
                            string settlement = "<input type=\"button\" onclick=\"javascript:window.location.href='" + OrderUrl + "'\" name=\"settlement\" id=\"settlement\"  value=\" \" />";
                            websiteContent = websiteContent.Replace("[#Pro_Settlement]", settlement);
                        }

                        if (websiteContent.IndexOf("[#Pro_DeteleButton]") > -1)
                        {
                            websiteContent = websiteContent.Replace("[#Pro_DeteleButton]", "<input type=\"button\" id=\"DeteleButton\" onclick=\"AbuthDle()\" value=\"删除\"></input>");
                        }
                        if (Str_Tag != "")
                        {
                            if (catrInfos.ToString() != string.Empty)
                            {
                                websiteContent = websiteContent.Replace(temptag, catrInfos.ToString());
                            }
                            else
                            {
                                websiteContent = websiteContent.Replace(temptag, "");
                            }
                            shtml.Append(websiteContent);
                        }
                        else
                        {
                            shtml.Append(catrInfos.ToString());
                        }

                        if (shtml.ToString() != string.Empty)
                        {
                            if (Str_Tag == "")
                            {
                                string ShopUrl = Common.UrlStr("productclass", "", "product/");
                                string OrderUrl = Common.UrlStr("makeorders", "UserTypeId=0;UserId=0", "product/");
                                shtml.Append("<ul class=\"shop5\">");
                                shtml.Append("<li class=\"shop5-1\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_img3.jpg\"><input type=\"button\" onclick=\"AbuthDle()\" value=\"删除\"></input></li>");
                                shtml.Append("<li class=\"shop5-2\"><a href=\"javascript:window.location.reload();\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt1.jpg\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt2.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + ShopUrl + "'\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt3.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + OrderUrl + "'\" border=\"0\"></a></li>");
                                shtml.Append("</ul>");
                            }
                        }
                        #endregion

                        #region 支付给商家
                        string StrId = "";

                        foreach (CartItemInfo Einfo in cart)
                        {
                            bool WhetherPutoutID = false;
                            YXShop.Model.Product.ProductInfo promodelp = productbll.GetModel(int.Parse(Einfo.ProductId));
                            if (promodelp != null)
                            {
                                int TyID = Convert.ToInt32(promodelp.pro_PutoutType);
                                int id = Convert.ToInt32(promodelp.pro_PutoutID);
                                if (TyID == 1)
                                {
                                    string[] ArreyStrId = StrId.Split(',');
                                    for (int k = 0; k < ArreyStrId.Length; k++)
                                    {
                                        if (ArreyStrId[k] == id.ToString())
                                        {
                                            WhetherPutoutID = true;
                                        }
                                    }
                                    if (!WhetherPutoutID)
                                    {
                                        StringBuilder cartInfoShop = new StringBuilder();
                                        double productTotalPrice2 = 0;
                                        double productTotalWeight2 = 0;
                                        double productTotalIntegral2 = 0;
                                        foreach (CartItemInfo info in cart)
                                        {
                                            YXShop.Model.Product.ProductInfo productmodel = productbll.GetModel(int.Parse(info.ProductId));
                                            if (productmodel != null)
                                            {
                                                if (id == productmodel.pro_PutoutID)
                                                {
                                                    if (Str_Tag != "")
                                                    {
                                                        StrContent = Str_Tag;
                                                    }
                                                    else
                                                    {
                                                        StrContent = mystyle;
                                                    }
                                                    double price = double.Parse(productmodel.pro_ShopPrice.ToString());
                                                    //配件
                                                    string fittingProductInfo = "";
                                                    double fittingTotalPrice = 0;
                                                    int fittingProductCount = 0;
                                                    double fittingProductWeight = 0;
                                                    double fittingProductIntergal = 0;
                                                    YXShop.Common.ProductInfo.FittingDisposal(info.SparepartId, info.FittingsProductId, info.FittingsProductCount, out fittingProductCount, out fittingProductInfo, out fittingTotalPrice, out fittingProductWeight, out fittingProductIntergal);
                                                    //规格

                                                    string memberPrice = productmodel.pro_RatingDiscount;
                                                    string productNo = productmodel.pro_NO;

                                                    if (!string.IsNullOrEmpty(productmodel.pro_Specifications.Trim()))
                                                    {
                                                        YXShop.Common.ProductInfo.SpecificationDisposal(Convert.ToInt32(info.ProductId), info.Specification, memberPrice, price, out price, out productNo);
                                                    }
                                                    double count = 0;
                                                    /*
                                                     *修改人:ym
                                                     *修改时间:2009.10.09
                                                     */
                                                    count = double.Parse(info.Quantity.ToString());
                                                    double total = price * count + fittingTotalPrice;
                                                    if (StrContent.IndexOf("[#CheckBox]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#CheckBox]", "<input id=\"cbTm\" type=\"checkbox\" name=\"ShoppCartID\" value=\"" + info.CartKey + "\" />");
                                                    }
                                                    if (StrContent.Contains("[#Pro_ItmeNo]"))
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_ItmeNo]", productNo);
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_ID]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_ID]", info.ProductId);
                                                    }
                                                    if (StrContent.Contains("[#Pro_Url]"))
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_Url]", Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/"));
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Images]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_Images]", sp.DummyPaht + productmodel.pro_Thumbnail);
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Name]") > -1)
                                                    {
                                                        string strUrl = Common.UrlStr("productcontent", "q_productid=" + info.ProductId + "", "product/");
                                                        string specification = info.Specification;
                                                        if (!string.IsNullOrEmpty(specification.Trim()))
                                                        {
                                                            specification = "(" + specification + ")";
                                                        }
                                                        StrContent = StrContent.Replace("[#Pro_Name]", "<a href=" + strUrl + " target='_blank'>" + productmodel.pro_Name + "&nbsp;" + specification + "</a>&nbsp;&nbsp;" + fittingProductInfo + "");
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_CID]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_CID]", productmodel.pro_CID);
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Price]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_Price]", productmodel.pro_MarketPrice.ToString());
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_ShopPrice]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_ShopPrice]", price.ToString("f2"));
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Integral]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_Integral]", (Convert.ToDouble(productmodel.pro_DonateIntegral) + fittingProductIntergal).ToString());
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_NeedIntegral]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_NeedIntegral]", productmodel.pro_IntegralPrice.ToString());
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_NeedDummyMoney]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_NeedDummyMoney]", productmodel.pro_EPoints.ToString());
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Count]") > -1)
                                                    {
                                                        /**
                                                         * kevin
                                                         * 修改时间：2009-12.14
                                                         */
                                                        StrContent = StrContent.Replace("[#Pro_Count]", "<input style=\"width: 36px\" onblur=\"UpdataShoppCart(this.value,'" + info.CartKey + "','" + productmodel.pro_ID + "')\" value=\"" + count.ToString() + "\" type=\"text\" />");
                                                    }
                                                    if (StrContent.IndexOf("[#Pro_Total]") > -1)
                                                    {
                                                        StrContent = StrContent.Replace("[#Pro_Total]", total.ToString("f2"));
                                                    }
                                                    productTotalPrice2 += total;
                                                    productTotalWeight2 += (Convert.ToDouble(productmodel.pro_Weight) * info.Quantity) + fittingProductWeight;
                                                    productTotalIntegral2 += (Convert.ToDouble(productmodel.pro_DonateIntegral) * info.Quantity) + fittingProductIntergal;

                                                    cartInfoShop.Append(StrContent);
                                                }
                                            }
                                        }
                                        string ShopInfo = mystyle;
                                        if (ShopInfo.IndexOf("[#Pro_TotalPrice]") > -1)
                                        {
                                            ShopInfo = ShopInfo.Replace("[#Pro_TotalPrice]", productTotalPrice2.ToString());
                                        }
                                        if (ShopInfo.IndexOf("[#Pro_TotalWeight]") > -1)
                                        {
                                            ShopInfo = ShopInfo.Replace("[#Pro_TotalWeight]", productTotalWeight2.ToString());
                                        }
                                        if (ShopInfo.IndexOf("[#Pro_TotalInter]") > -1)
                                        {
                                            ShopInfo = ShopInfo.Replace("[#Pro_TotalInter]", productTotalIntegral2.ToString());
                                        }

                                        if (ShopInfo.IndexOf("[#Pro_ContinueButton]") > -1)
                                        {
                                            string continueButton = "<input type=\"button\" name=\"ContinueButton\" id=\"ContinueButton\" onclick=\"javascript:window.history.back();\" value=\" \" />";
                                            ShopInfo = ShopInfo.Replace("[#Pro_ContinueButton]", continueButton);
                                        }

                                        if (ShopInfo.IndexOf("[#Pro_Settlement]") > -1)
                                        {
                                            string Store_OrderUrl = Common.UrlStr("makeorders", "UserTypeId=1;UserId=" + id + "", "product/");
                                            string settlement = "<input type=\"button\" onclick=\"javascript:window.location.href='" + Store_OrderUrl + "'\" name=\"settlement\" id=\"settlement\"  value=\" \" />";
                                            ShopInfo = ShopInfo.Replace("[#Pro_Settlement]", settlement);
                                        }

                                        if (ShopInfo.IndexOf("[#Pro_DeteleButton]") > -1)
                                        {
                                            ShopInfo = ShopInfo.Replace("[#Pro_DeteleButton]", "<input type=\"button\" id=\"DeteleButton\" onclick=\"AbuthDle()\" value=\"删除\"></input>");
                                        }
                                        if (Str_Tag != "")
                                        {
                                            if (cartInfoShop.ToString() != string.Empty)
                                            {
                                                ShopInfo = ShopInfo.Replace(temptag, cartInfoShop.ToString());
                                            }
                                            else
                                            {
                                                ShopInfo = ShopInfo.Replace(temptag, "");
                                            }
                                            shtml.Append(ShopInfo);
                                        }
                                        else
                                        {
                                            shtml.Append(cartInfoShop.ToString());
                                        }

                                        if (Str_Tag == "")
                                        {
                                            string Store_ShopUrl = Common.UrlStr("productclass", "", "product/");
                                            string Store_OrderUrl = Common.UrlStr("makeorders", "UserTypeId=1;UserId=" + id + "", "product/");
                                            shtml.Append("<ul class=\"shop5\">");
                                            shtml.Append("<li class=\"shop5-1\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_img3.jpg\"><input type=\"button\" onclick=\"AbuthDle()\" value=\"删除\"></input></li>");
                                            shtml.Append("<li class=\"shop5-2\"><a href=\"javascript:window.location.reload();\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt1.jpg\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt2.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + Store_ShopUrl + "'\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"#\"><img src=\"" + sp.DummyPaht + sp.WebSiteTemplatePath + "/images/shop_bt3.jpg\" style=\"cursor:hand\" onclick=\"window.location.href='" + Store_OrderUrl + "'\" border=\"0\"></a></li>");
                                            shtml.Append("</ul>");
                                        }
                                        if (StrId == string.Empty)
                                        {
                                            StrId = id.ToString();
                                        }
                                        else
                                        {
                                            StrId += "," + id.ToString();
                                        }

                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    return "系统设置错误！没有相关的模板信息，请自行设置";
                }
            }
            else
            {
                return "您暂时还没有添加任何商品，请返回继续购买";
            }


            return shtml.ToString();
        }
    }
}